# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.ProximityBeacon.V1beta1.Model.EphemeralIdRegistration do
  @moduledoc """
  Write-only registration parameters for beacons using Eddystone-EID format.
  Two ways of securely registering an Eddystone-EID beacon with the service
  are supported:

  1. Perform an ECDH key exchange via this API, including a previous call
     to `GET /v1beta1/eidparams`. In this case the fields
     `beacon_ecdh_public_key` and `service_ecdh_public_key` should be
     populated and `beacon_identity_key` should not be populated. This
     method ensures that only the two parties in the ECDH key exchange can
     compute the identity key, which becomes a secret between them.
  2. Derive or obtain the beacon's identity key via other secure means
     (perhaps an ECDH key exchange between the beacon and a mobile device
     or any other secure method), and then submit the resulting identity key
     to the service. In this case `beacon_identity_key` field should be
     populated, and neither of `beacon_ecdh_public_key` nor
     `service_ecdh_public_key` fields should be. The security of this method
     depends on how securely the parties involved (in particular the
     bluetooth client) handle the identity key, and obviously on how
     securely the identity key was generated.

  See [the Eddystone
  specification](https://github.com/google/eddystone/tree/master/eddystone-eid)
  at GitHub.

  ## Attributes

  *   `beaconEcdhPublicKey` (*type:* `String.t`, *default:* `nil`) - The beacon's public key used for the Elliptic curve Diffie-Hellman
      key exchange. When this field is populated, `service_ecdh_public_key`
      must also be populated, and `beacon_identity_key` must not be.
  *   `beaconIdentityKey` (*type:* `String.t`, *default:* `nil`) - The private key of the beacon. If this field is populated,
      `beacon_ecdh_public_key` and `service_ecdh_public_key` must not be
      populated.
  *   `initialClockValue` (*type:* `String.t`, *default:* `nil`) - The initial clock value of the beacon. The beacon's clock must have
      begun counting at this value immediately prior to transmitting this
      value to the resolving service. Significant delay in transmitting this
      value to the service risks registration or resolution failures. If a
      value is not provided, the default is zero.
  *   `initialEid` (*type:* `String.t`, *default:* `nil`) - An initial ephemeral ID calculated using the clock value submitted as
      `initial_clock_value`, and the secret key generated by the
      Diffie-Hellman key exchange using `service_ecdh_public_key` and
      `service_ecdh_public_key`. This initial EID value will be used by the
      service to confirm that the key exchange process was successful.
  *   `rotationPeriodExponent` (*type:* `integer()`, *default:* `nil`) - Indicates the nominal period between each rotation of the beacon's
      ephemeral ID. "Nominal" because the beacon should randomize the
      actual interval. See [the spec at
      github](https://github.com/google/eddystone/tree/master/eddystone-eid)
      for details. This value corresponds to a power-of-two scaler on the
      beacon's clock: when the scaler value is K, the beacon will begin
      broadcasting a new ephemeral ID on average every 2^K seconds.
  *   `serviceEcdhPublicKey` (*type:* `String.t`, *default:* `nil`) - The service's public key used for the Elliptic curve Diffie-Hellman
      key exchange. When this field is populated, `beacon_ecdh_public_key`
      must also be populated, and `beacon_identity_key` must not be.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :beaconEcdhPublicKey => String.t(),
          :beaconIdentityKey => String.t(),
          :initialClockValue => String.t(),
          :initialEid => String.t(),
          :rotationPeriodExponent => integer(),
          :serviceEcdhPublicKey => String.t()
        }

  field(:beaconEcdhPublicKey)
  field(:beaconIdentityKey)
  field(:initialClockValue)
  field(:initialEid)
  field(:rotationPeriodExponent)
  field(:serviceEcdhPublicKey)
end

defimpl Poison.Decoder, for: GoogleApi.ProximityBeacon.V1beta1.Model.EphemeralIdRegistration do
  def decode(value, options) do
    GoogleApi.ProximityBeacon.V1beta1.Model.EphemeralIdRegistration.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.ProximityBeacon.V1beta1.Model.EphemeralIdRegistration do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
